#ifndef __CONVEX_HULL_CREATOR_DIALOG_HPP__
#define __CONVEX_HULL_CREATOR_DIALOG_HPP__

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <vector>

#include <wx/propgrid/propgrid.h>

#include "SmegEditor_gui.h"

#include "../Canvas/ConvexHullCreatorCanvas.hpp"
#include "../ObjectHandler/Lights/ConvexHullHandler.hpp"

namespace smeg {
    namespace light {
        class ConvexHull;
    }
}

////////////////////////////////////////////////////////////
/// Defines
////////////////////////////////////////////////////////////
#define wxID_VERTEX_PROPERTY 3001

////////////////////////////////////////////////////////////
/// ConvexHullCreatorDialog is a dialog to create ConvexHull
////////////////////////////////////////////////////////////
class ConvexHullCreatorDialog : public ConvexHullCreatorDialogGUI
{
    public:
        ////////////////////////////////////////////////////////////
        /// Construct the ConvexHullCreatorDialog
        ///
        /// \param _pParent :         Parent of the frame
        /// \param _pConvexHull :    Convex hull for this dialog
        ///
        ////////////////////////////////////////////////////////////
		                            ConvexHullCreatorDialog( wxWindow* _pParent, smeg::light::ConvexHull* _pConvexHull = NULL );
        
        ////////////////////////////////////////////////////////////
        /// Set the convex hull
        ///
        /// \param _pConvexHull :   Convex hull for this dialog
        ///
        ////////////////////////////////////////////////////////////
        void                        SetConvexHull( smeg::light::ConvexHull* _pConvexHull );

        ////////////////////////////////////////////////////////////
        /// When a vertex was moved in the canvas
        ///
        /// \param _iNumVertex :    Index of the moved vertex
        /// \param _x :             New X pos
        /// \param _y :             New Y pos
        ///
        ////////////////////////////////////////////////////////////
        void                        OnVertexMoved( int _iNumVertex, float _x, float _y );

        ////////////////////////////////////////////////////////////
        /// Get the filename for the convex Hull
        ///
        /// \return The filename for the convex Hull
        ///
        ////////////////////////////////////////////////////////////
        const wxFileName&           GetFilename() const;

    protected:
        ////////////////////////////////////////////////////////////
        /// Save a ConvexHull to a file
        ///
        /// \param _Filename : file to save the ConvexHull
        ///
        /// \return :       Whether the ConvexHull was successfully saved or not
        ///
        ////////////////////////////////////////////////////////////
        bool                SaveConvexHull( const wxString& _Filename );

        ////////////////////////////////////////////////////////////
		/// Event handlers
        ///
        ////////////////////////////////////////////////////////////
        virtual void        OnValidateConvexHull( wxCommandEvent& event );
        virtual void        OnCancelConvexHull( wxCommandEvent& event );
        virtual void        OnNumVerticesChanged( wxSpinEvent& event );
        virtual void        OnPropertyChanged( wxPropertyGridEvent& event );

        /******************* Protected members ********************/
        wxFileName                  m_Filename;
        smeg::light::ConvexHull*    m_pConvexHull;

        ConvexHullCreatorCanvas*    m_pCanvas;
        wxPropertyGrid*             m_pPropertyGrid;

        wxSpinCtrlDouble*           m_pSizeMultiplierSpin;

        int                         m_uNumCurrentVertices;
};
        
////////////////////////////////////////////////////////////
/// Set the convex hull handler
////////////////////////////////////////////////////////////
inline void ConvexHullCreatorDialog::SetConvexHull( smeg::light::ConvexHull* _pConvexHull ) {
    m_pConvexHull = _pConvexHull;
}

////////////////////////////////////////////////////////////
/// Get the filename for the convex Hull
////////////////////////////////////////////////////////////
inline const wxFileName& ConvexHullCreatorDialog::GetFilename() const {
    return m_Filename;
}

#endif // __CONVEX_HULL_CREATOR_DIALOG_HPP__
